from django.utils.deprecation import MiddlewareMixin


class CORSMiddleware(MiddlewareMixin):
    def process_response(self, request, response):
        # 添加响应头
        # 允许你的域名来获取我的数据
        # 允许所有的域名来获取数据
        response['Access-Control-Allow-Origin'] = '*'

        # 允许你携带Content-Type请求头 如果要多的用逗号,隔开
        response['Access-Control-Allow-Headers'] = '*'
        return response